package com.haitonghop.utils.sqllite.helper;

import com.haitonghop.modules.truyentranh.TruyenTranhSession;
import com.haitonghop.utils.Logger;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class SQLiteTruyenTranhBookmarkHelper extends SQLLiteHelper {

//	TruyenTranhSession.currentComic.title = currentComic.title;
//	TruyenTranhSession.currentComic.avatar = currentComic.avatar;
//	TruyenTranhSession.currentComic.href = currentComic.href;	
//
//	TruyenTranhSession.currentChapter.readUrl = currentChapter.readUrl;
//	TruyenTranhSession.currentChapter.name = currentChapter.name;
//	TruyenTranhSession.currentPage = currentPage;
	
	public static final String TABLE_COMICS = "truyentranhbookmark";
	public static final String COLUMN_ID = "id"; //md5 TruyenTranhSession.currentChapter.readUrl
	
	//current commic
	public static final String COLUMN_TITLE = "title";
	public static final String COLUMN_AVATAR = "avatar";
	public static final String COLUMN_HREF = "href";	
	//current chapter
	public static final String COLUMN_READURL = "readUrl";
	public static final String COLUMN_NAME = "name";
	public static final String COLUMN_PAGE = "currentPage";
	
	public static final String COLUMN_STATE = "state";

	// Database creation sql statement
	private static final String DATABASE_CREATE = "create table "
			+ TABLE_COMICS + "(" 
			+ COLUMN_ID + " text primary key , "
			+ COLUMN_TITLE + " text not null," 
			+ COLUMN_AVATAR + " text not null," 
			+ COLUMN_HREF + " text not null," 
			+ COLUMN_READURL + " text not null," 
			+ COLUMN_NAME + " text not null," 			 
			+ COLUMN_PAGE + " int not null,"
			+ COLUMN_STATE + " int not null);";

	public SQLiteTruyenTranhBookmarkHelper(Context context) {		
		super(context);
		Logger.logMe(">>>>>>>>>>>>>>>>> SQLiteHaiBLMetalDataCachedHelper");
	}

	@Override
	public void onCreate(SQLiteDatabase database) {
		Logger.logMe(">>>>>>>>>>>>>>>>> onCreate = "+DATABASE_CREATE);
		database.execSQL(DATABASE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		Log.w(SQLiteHaiBLMetalDataCachedHelper.class.getName(),
				"Upgrading database from version " + oldVersion + " to "
						+ newVersion + ", which will destroy all old data");
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_COMICS);
		onCreate(db);
	}

}
